package com.iweb.user.controller;

import com.iweb.user.model.Order;
import com.iweb.user.service.UserOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api")
@CrossOrigin
public class OrderController {

    @Autowired
    private UserOrderService userOrderService;

    // 这个 Controller 现在只负责创建订单，职责单一且清晰
    @PostMapping("/orders")
    public Order createOrder(@RequestBody Order order) {
        return userOrderService.createOrder(order);
    }


}